home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 008 / src / hack.tty.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  3KB  |  153 lines

  1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */
  2.  
  3. #include   "hack.h"
  4. #include   <stdio.h>
  5.  
  6. char inchar();
  7.  
  8. gettty(){
  9. }
  10.  
  11. /* reset terminal to original state */
  12. settty(s) char *s; {
  13.    clear_screen();
  14.    if(s) myprintf(s);
  15.    (void) myfflush(stdout);
  16.    flags.echo = OFF;
  17.    flags.cbreak = OFF;
  18. }
  19.  
  20. setctty(){
  21. }
  22.  
  23. setftty(){
  24. }
  25.  
  26. echo(n)
  27. register int n;
  28. {
  29. }
  30.  
  31. /* always want to expand tabs, or to send a clear line char before
  32.    printing something on topline */
  33. xtabs()
  34. {
  35. }
  36.  
  37. #ifdef LONG_CMD
  38. cbreak(n)
  39. register int n;
  40. {
  41. }
  42. #endif LONG_CMD
  43.  
  44. getlin(bufp)
  45. register char *bufp;
  46. {
  47.    register char *obufp = bufp;
  48.    register int c;
  49.  
  50.    flags.topl = 2;      /* nonempty, no --More-- required */
  51.    for(;;) {
  52.       (void) myfflush(stdout);
  53.       c = inchar();
  54.       if(c == '\b') {
  55.          if(bufp != obufp) {
  56.             bufp--;
  57.             putstr("\b \b"); /* putsym converts \b */
  58.          } else   bell();
  59.       } else if(c == '\n') {
  60.          *bufp = 0;
  61.          return;
  62.       } else {
  63.          *bufp = c;
  64.          bufp[1] = 0;
  65.          putstr(bufp);
  66.          if(bufp-obufp < BUFSZ-1 && bufp-obufp < COLNO)
  67.             bufp++;
  68.       }
  69.    }
  70. }
  71.  
  72. getret() {
  73.    xgetret(TRUE);
  74. }
  75.  
  76. cgetret() {
  77.    xgetret(FALSE);
  78. }
  79.  
  80. xgetret(spaceflag)
  81. boolean spaceflag;   /* TRUE if space (return) required */
  82. {
  83.    myprintf("\nHit %s to continue: ",
  84.       flags.cbreak ? "space" : "return");
  85.    xwaitforspace(spaceflag);
  86. }
  87.  
  88. char morc;   /* tell the outside world what char he used */
  89.  
  90. xwaitforspace(spaceflag)
  91. boolean spaceflag;
  92. {
  93. register int c;
  94.  
  95.    (void) myfflush(stdout);
  96.    morc = 0;
  97.  
  98.    while((c = inchar()) != '\n')
  99.       {
  100.       if (flags.cbreak)
  101.          {
  102.          if (c == ' ')
  103.             break;
  104.          if (!spaceflag && letter(c))
  105.             {
  106.             morc = c;
  107.             break;
  108.             }
  109.          }
  110.       }
  111.    }
  112.  
  113. char *
  114. parse()
  115. {
  116.    static char inline[COLNO];
  117.    register int foo;
  118.  
  119.    flags.move = 1;
  120.    if(!Invis) curs(u.ux,u.uy+2); else home();
  121.    (void) myfflush(stdout);
  122.    while((foo = inchar()) >= '0' && foo <= '9')
  123.       multi += 10*multi+foo-'0';
  124.    if(multi) {
  125.       multi--;
  126.       save_cm = inline;
  127.    }
  128.    inline[0] = foo;
  129.    inline[1] = 0;
  130.    if(foo == 'f' || foo == 'F'){
  131.       inline[1] = inchar();
  132. #ifdef QUEST
  133.       if(inline[1] == foo) inline[2] = inchar(); else
  134. #endif QUEST
  135.       inline[2] = 0;
  136.    }
  137.    if(foo == 'm' || foo == 'M'){
  138.       inline[1] = inchar();
  139.       inline[2] = 0;
  140.    }
  141.    clrlin();
  142.    return(inline);
  143. }
  144.  
  145. char
  146. readchar() {
  147.    register int sym;
  148.    (void) myfflush(stdout);
  149.    sym = inchar();
  150.    if(flags.topl == 1) flags.topl = 2;
  151.    return((char) sym);
  152. }
  153.